//
//  VideoView.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/13.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "VideoView.h"

#define kTitleY kScreenIp6(20)
#define kBtnWidth kScreenIp6(60)
#define kBtnHeight kScreenIp6(40)

@interface VideoView ()

@end

@implementation VideoView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addBackImageView];
        
        
        CGFloat liveScrollViewH = kScreenHeight - kScreenIp6(109) - 48;
        
        self.baseScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, kScreenIp6(109), kScreenWidth, liveScrollViewH)];
        _baseScrollView.contentSize = CGSizeMake(kScreenWidth * 3, 0);
        self.baseScrollView.backgroundColor = [UIColor clearColor];
        
        [self addScrollView];
        
        
        self.recommendBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.recommendBtn.frame = CGRectMake(0, kScreenIp6(64), kScreenWidth / 3, kScreenIp6(46));
        self.recommendBtn.userInteractionEnabled = YES;
        [self.recommendBtn setTitle:@"推荐" forState:UIControlStateNormal];
        [self.recommendBtn setTintColor:[UIColor whiteColor]];
        [self.backImageView addSubview:_recommendBtn];
        
        self.collectionBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.collectionBtn.frame = CGRectMake(kScreenWidth / 3, kScreenIp6(64), kScreenWidth / 3, kScreenIp6(46));
        self.collectionBtn.userInteractionEnabled = YES;
        [self.collectionBtn setTitle:@"集锦" forState:UIControlStateNormal];
        [self.collectionBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        [self.backImageView addSubview:_collectionBtn];
        
        self.videoBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.videoBtn.frame = CGRectMake(kScreenWidth * 2 / 3,kScreenIp6(64), kScreenWidth / 3, kScreenIp6(46));
        [self.videoBtn setTitle:@"录像" forState:UIControlStateNormal];
        [self.videoBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        [self.backImageView addSubview:_videoBtn];
        
        
        self.pointImage = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.pointImage setImage:[UIImage imageNamed:@"point"] forState:UIControlStateNormal];
        self.pointImage.bounds = CGRectMake(0, 0, kScreenIp6(15), kScreenIp6(20));
        self.pointImage.center = CGPointMake(kScreenWidth/6, kScreenIp6(106));
        [self.pointImage setTintColor:[UIColor whiteColor]];
        [self.backImageView addSubview:_pointImage];
        
    }
    return self;
}

#pragma mark - 添加背景视图
- (void)addBackImageView
{
    
    self.backImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.backImageView.image = [UIImage imageNamed:@"BackImage"];
    self.backImageView.userInteractionEnabled = YES;
    
    self.leftButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.leftButton.frame = CGRectMake((kScreenWidth - kBtnWidth- kScreenIp6(10)) / 2, kTitleY, kBtnWidth, kBtnHeight);
    [self.leftButton setTitle:@"足球" forState:UIControlStateNormal];
    self.leftButton.titleLabel.font = [UIFont systemFontOfSize:18];
    [self.leftButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.backImageView addSubview:_leftButton];
    
    self.rightButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.rightButton.frame = CGRectMake(kScreenWidth/2, self.leftButton.frame.origin.y, kScreenWidth/2, kBtnHeight);
    [self.rightButton setTitle:@"篮球" forState:UIControlStateNormal];
    self.rightButton.titleLabel.font = [UIFont systemFontOfSize:18];
    [self.rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    self.rightButton.titleEdgeInsets = UIEdgeInsetsMake(0, kScreenIp6(20), 0, 0);
    [self.backImageView addSubview:_rightButton];
    self.rightButton.hidden = YES;
    
    self.nextButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.nextButton.frame = CGRectMake(self.leftButton.frame.origin.x + kBtnWidth, self.leftButton.frame.origin.y + (kBtnHeight - kScreenIp6(15))/2, kScreenIp6(10), kScreenIp6(15));
    [self.nextButton setImage:[UIImage imageNamed:@"next"] forState:UIControlStateNormal];
    [self.nextButton setTintColor:[UIColor whiteColor]];
    [self.backImageView addSubview:_nextButton];
    
    
    [self addSubview:self.backImageView];
    
}

#pragma mark - 添加 ScrollView
- (void)addScrollView
{
    self.baseScrollView.contentOffset = CGPointMake(0, 0);
    self.baseScrollView.showsHorizontalScrollIndicator = NO;
    self.baseScrollView.bounces = NO;
    self.baseScrollView.pagingEnabled = YES;
    
    self.leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.baseScrollView.bounds.size.height)];
    self.leftTableView.backgroundColor = [UIColor clearColor];
    [self.baseScrollView addSubview:_leftTableView];
    
    self.centerTableView = [[UITableView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, self.baseScrollView.bounds.size.height)];
    self.centerTableView.backgroundColor = [UIColor clearColor];
    [self.baseScrollView addSubview:_centerTableView];
    
    self.rightTableView = [[UITableView alloc] initWithFrame:CGRectMake(kScreenWidth * 2, 0, kScreenWidth, self.baseScrollView.bounds.size.height)];
    self.rightTableView.backgroundColor = [UIColor clearColor];
    [self.baseScrollView addSubview:_rightTableView];
    
    [self.backImageView addSubview:_baseScrollView];
}




@end
